<?php
	include_once "dataservice.php";
	
	class loainguoidung_db
	{
		public function Them($MaLoaiNguoiDung, $TenLoaiNguoiDung = "")
		{
			$sql = "INSERT INTO `tbl_loainguoidung`(`MaLoaiNguoiDung`, `TenLoaiNguoiDung`) 
					VALUES ($MaLoaiNguoiDung, '$TenLoaiNguoiDung')";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function CapNhat($MaLoaiNguoiDung, $TenLoaiNguoiDung)
		{
			$sql = "UPDATE `tbl_loainguoidung` 
					SET `TenLoaiNguoiDung`=[value-2]
					WHERE `MaLoaiNguoiDung`='$TenLoaiNguoiDung'";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function Xoa($MaLoaiNguoiDung)
		{
			$sql = "DELETE FROM `tbl_nguoidung` WHERE MaNguoiDung = $MaNguoiDung";
			
			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}
		
		public function LayDanhSach($MaLoaiNguoiDung)
		{
			$sql = "SELECT * FROM `tbl_loainguoidung` WHERE 1";
			
			if($MaLoaiNguoiDung != -1)
				$sql .= " AND MaLoaiNguoiDung = '$MaLoaiNguoiDung'";
			
			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}
	}
?>